<%@ Register TagPrefix="cc1" Namespace="PHSRAG.Insight21.InsightWebControls" Assembly="PHSRAG.Insight21.InsightWebControls" %>
<%@ Register TagPrefix="cc2" Namespace="PHSRAG.WebControls" Assembly="PHSRAG.WebControls" %>

<%@ Page Language="c#" Inherits="PHSRAG.Insight21.COI.HierarchyMaintenance" CodeFile="HierarchyMaintenance.aspx.cs" %>

<%@ Register TagPrefix="uc1" TagName="userImpersonation" Src="UserImpersonation.ascx" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>COI-Hierarchy Maintenance</title>
    <link href="../Insight21.css" type="text/css" rel="stylesheet" />

    <script language="javascript" type="text/javascript">
		function ConfirmAction(controlId,fullName)
		{
		try
			{
				var removeUser=document.getElementById(controlId);
				var confirmControl = document.getElementsByName('ConfirmationFlag');
				if (removeUser != null && removeUser.checked)
				{		
				if (confirmControl != null)
					{
					if (confirm('Are you sure you want to remove '+fullName+' from the hierarchy?'))
							{
								confirmControl(0).value = "True";
							}
							else
							{confirmControl(0).value = "False"}													    
					}	
				}	
			}
			catch(e)
			{
				document.write(e.message);
			}								
			
		}	
		
		function OnEndRequest(sender, eventArgs) 
		{
			//Inform activity indicator that the partial-page rendering is complete
			if (EndFeedback != null)
				EndFeedback();
		}	
    </script>

</head>
<body>
    <form id="Form1" method="post" runat="server">
        <asp:ScriptManager ID="scriptManager" runat="server">
        </asp:ScriptManager>

        <script type="text/javascript">
			Sys.WebForms.PageRequestManager.getInstance().add_endRequest(OnEndRequest);
        </script>

        <table class="Container" width="100%">
            <tr>
                <td>
                    <asp:Panel ID="headerSection" runat="server">
                        <table class="Header" width="100%">
                            <tr>
                                <td>
                                    <cc1:Header ID="header" runat="server"></cc1:Header>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <cc1:CoISubNavigation ID="coiSubNavigation" runat="server"></cc1:CoISubNavigation>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <cc2:BreadCrumb ID="breadCrumb" runat="server" HighlightCurrentPage="true"></cc2:BreadCrumb>
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                    <cc2:PostbackGuard ID="postbackGuard" runat="server"></cc2:PostbackGuard>
                    <table class="Invisible" id="dynamicTable" width="100%" border="0">
                        <tr>
                            <td>
                                <cc2:Annunciator ID="annunciator" ContainerID="dynamicTable" runat="server"></cc2:Annunciator>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <cc2:ActivityIndicator ID="activityIndicator" ContainerID="dynamicTable" runat="server">
                                </cc2:ActivityIndicator>
                            </td>
                        </tr>
                    </table>
                    <table class="FormsManagement" cellspacing="5" cellpadding="5" width="100%" style="background-color:#ffffff">
                        <tr>
                            <td>
                                <cc2:ExpandingPanel ID="helpContainer" runat="server" ExpansionToggler="expansionToggler">
                                    <StaticTemplate>
                                        <table class="Search">
                                            <tr>
                                                <td>
                                                    <table id="expandedSearch" runat="server" width="100%">
                                                        <tr style="width:100%">
                                                            <td style="width:100%">
                                                                <table width="100%">
                                                                    <tr>
                                                                        <td>
                                                                            <cc1:COISearch ID="coISearch" ViewOptionVisible="false" DefaultHierarchyType="None" runat="server"></cc1:COISearch>
                                                                        </td>
                                                                        <td>
                                                                            <cc1:CommonSearch ID="commonSearch" HideAllCommonControls="true" runat="server" ExtendedSearchControl="coISearch"
                                                                                OnSearch="OnSearch" OnClearSelection="OnClearSelection" ViewOptionVisible="false"
                                                                                Module="COI"></cc1:CommonSearch>
                                                                        </td>
                                                                    </tr>
                                                                </table>
                                                            </td>
                                                        </tr>
                                                        <tr style="display: none">
                                                            <td class="PanelSeparator">
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td>
                                                                <cc2:ExpansionToggler ID="expansionToggler" runat="Server" ExpandedImage="~/Images/Arrow_DN.gif"
                                                                    CollapsedImage="~/Images/Arrow_RT.gif" ExpandedLinkCaption="Hide Instructions"
                                                                    CollapsedLinkCaption="Show Instructions"></cc2:ExpansionToggler>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                        </table>
                                    </StaticTemplate>
                                    <DynamicTemplate>
                                        <table class="SearchDynamic">
                                            <tr>
                                                <td>
                                                    To search for an individual in your reporting hierarchy, enter their first and last
                                                    name, or their Partners log-in (e.g., XYZ12).
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    If you have questions, please contact Anne Botelho at 617.643.4494 or email <a href="mailto:COIAdmin@partners.org">
                                                        COIAdmin@partners.org.</a>
                                                </td>
                                            </tr>
                                        </table>
                                    </DynamicTemplate>
                                </cc2:ExpandingPanel>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <cc1:SearchCriteriaDisplay ID="searchCriteriaDisplay" runat="server"></cc1:SearchCriteriaDisplay>
                            </td>
                        </tr>
                    </table>
                    <asp:Panel ID="impersonationPanel" runat="server" Visible="false">
                        <table class="COIContainer" width="100%">
                            <tr>
                                <td>
                                    <uc1:userImpersonation ID="userImpersonation" runat="server"></uc1:userImpersonation>
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                    <br />
                    <asp:Panel ID="gridContainer" runat="server" Visible="False">
                        <asp:Panel ID="downloadBarContainer" Visible="False" runat="server">
                            <table class="PlaceBar" width="100%">
                                <tr>
                                    <td align="right">
                                        <cc2:DownloadBar ID="downloadBar" runat="server"></cc2:DownloadBar>
                                    </td>
                                </tr>
                            </table>
                        </asp:Panel>
                        <br />
                        <table class="DataTitle" width="100%">
                            <tr>
                                <td>
                                    &nbsp;
                                    <asp:Label ID="recordCount" runat="server"></asp:Label>&nbsp;Records
                                    <asp:Label ID="feedDate" runat="server"></asp:Label></td>
                            </tr>
                        </table>
                        <table width="100%">
                            <tr>
                                <td>
                                    <cc2:Pager ID="topPager" runat="server"></cc2:Pager>
                                </td>
                            </tr>
                        </table>
                        <table cellspacing="0" width="100%">
                            <tr>
                                <td>
                                    <asp:UpdatePanel ID="upUsersList" runat="server">
                                        <ContentTemplate>
                                            <asp:DataGrid ID="usersList" runat="server" AllowSorting="True" AutoGenerateColumns="False"
                                                AllowPaging="True" AllowCustomPaging="True" CssClass="DataGrid" Width="100%">
                                                <FooterStyle CssClass="DataGridHeader"></FooterStyle>
                                                <AlternatingItemStyle CssClass="DataGridAlternatingItem"></AlternatingItemStyle>
                                                <ItemStyle CssClass="DataGridItem"></ItemStyle>
                                                <HeaderStyle CssClass="DataGridHeader"></HeaderStyle>
                                                <Columns>
                                                    <asp:TemplateColumn HeaderText="Name" SortExpression="LastName">
                                                        <ItemTemplate>
                                                            <asp:Label ID="name" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.Name")%>'>
                                                            </asp:Label>
                                                        </ItemTemplate>
                                                    </asp:TemplateColumn>
                                                    <asp:TemplateColumn HeaderText="UserName" SortExpression="userName">
                                                        <ItemTemplate>
                                                            <asp:Label ID="userName" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.UserName")%>'>
                                                            </asp:Label>
                                                        </ItemTemplate>
                                                    </asp:TemplateColumn>
                                                    <asp:TemplateColumn HeaderText="Role">
                                                        <ItemTemplate>
                                                            <asp:Label runat="server" ID="roleLabel" Text='<%#DataBinder.Eval(Container, "DataItem.COIRole")%>'>
                                                            </asp:Label>
                                                        </ItemTemplate>
                                                        <EditItemTemplate>
                                                            <asp:DropDownList runat="server" ID="roles" CssClass="StaffDropDownList" DataTextField="Text"
                                                                DataValueField="Value" DataSource='<%#GetCOIRoles%>'>
                                                            </asp:DropDownList>
                                                        </EditItemTemplate>
                                                    </asp:TemplateColumn>
                                                    <asp:TemplateColumn HeaderText="Hierarchy Type">
                                                        <ItemTemplate>
                                                            <asp:Label runat="server" ID="lblHierarchyType" Text='<%#DataBinder.Eval(Container, "DataItem.HierarchyTypeId")%>' />
                                                        </ItemTemplate>
                                                        <EditItemTemplate>
                                                            <asp:DropDownList runat="server" ID="ddlHierarchyTypes" CssClass="StaffDropDownList" DataTextField="Text" DataValueField="Value" DataSource='<%#GetHierarchyTypes%>' />
                                                        </EditItemTemplate>
                                                    </asp:TemplateColumn>
                                                    <asp:TemplateColumn HeaderText="Outside Trustee" HeaderStyle-HorizontalAlign="center"
                                                        ItemStyle-HorizontalAlign="Center">
                                                        <ItemTemplate>
                                                            <asp:Label runat="server" ID="outSideTrustee" Text='<%#DataBinder.Eval(Container, "DataItem.OutsideMember")%>'>
                                                            </asp:Label>
                                                        </ItemTemplate>
                                                        <EditItemTemplate>
                                                            <asp:CheckBox runat="server" ID="outsideTrustees"></asp:CheckBox>
                                                        </EditItemTemplate>
                                                    </asp:TemplateColumn>
                                                    <asp:TemplateColumn HeaderText="Remove" ItemStyle-HorizontalAlign="Center">
                                                        <ItemTemplate>
                                                            <asp:CheckBox ID="removeUser" runat="server"></asp:CheckBox>
                                                        </ItemTemplate>
                                                    </asp:TemplateColumn>
                                                    <asp:EditCommandColumn EditText="Edit" CancelText="Cancel" UpdateText="Save" HeaderText="Action">
                                                    </asp:EditCommandColumn>
                                                </Columns>
                                                <PagerStyle Visible="False"></PagerStyle>
                                            </asp:DataGrid>
                                            <asp:HiddenField ID="hdnHierarchyTypeId" runat="server" Value="" />
                                        </ContentTemplate>
                                    </asp:UpdatePanel>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <cc2:Pager ID="bottomPager" runat="server"></cc2:Pager>
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                    <asp:Panel ID="supervisorInstruction" runat="server" Visible="True">
                        <table class="DataTitle" width="100%">
                            <tr>
                                <td align="center">
                                    <asp:Label ID="supervisorInfo" runat="server">For any questions or to modify the list of users, please contact <a href="mailto:COIAdmin@partners.org">
												PHS COI ADMIN</a></asp:Label></td>
                            </tr>
                        </table>
                    </asp:Panel>
                    <table>
                        <tr>
                            <td>
                                &nbsp;<asp:ImageButton ID="addUser" runat="server" Visible="false" ImageUrl="../Images/b_add_users.gif">
                                </asp:ImageButton></td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        
    </form>
</body>
</html>
